﻿using System;
using System.Collections.Generic;
using System.Web;
using PayRoller.Code;
using System.Web.SessionState;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using HySoft.Cash.Business;
using HySoft.Cash.Structure;
using System.Configuration;
using System.Web.Profile;

namespace PayRoller.Manage.OrgInfo
{
    public class InvoiceDel : ParentPage, IRequiresSessionState
    {
        // Fields
        protected HtmlForm form1;

        // Methods
        protected override void OnInit(EventArgs e)
        {
            base.m_ModuleCode = "0012";
            base.CheckLogin(true);
            base.CheckPerm();
            base.OnInit(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (base.Request["Sid"] != null)
            {
                TinvoicelistBN tbn = new TinvoicelistBN(this.Page);
                TinvoicelistDT detail = tbn.Get(Convert.ToInt32(base.Request["Sid"]));
                detail.IsValid = InvoiceStatuses.Deleted;
                tbn.Edit(detail);
                tbn.Dispose();
                tbn = null;
                string str = base.Request["OrgSid"].ToString();
                switch (Convert.ToInt32(base.Request["type"]))
                {
                    case 1:
                        base.ClientScript.RegisterStartupScript(base.GetType(), "", "<script>alert('Success!');window.location='InvoicesList.aspx?OrgSid=" + str + "';</script>");
                        return;

                    case 2:
                        base.ClientScript.RegisterStartupScript(base.GetType(), "", "<script>alert('Success!');window.location='../Invoices/AllInvoice.aspx';</script>");
                        return;

                    case 3:
                        base.ClientScript.RegisterStartupScript(base.GetType(), "", "<script>alert('Success!');window.location='../Invoices/OverduePayment.aspx';</script>");
                        return;

                    case 4:
                        base.ClientScript.RegisterStartupScript(base.GetType(), "", "<script>alert('Success!');window.location='../Invoices/ComingPayment.aspx';</script>");
                        return;

                    case 5:
                        base.ClientScript.RegisterStartupScript(base.GetType(), "", "<script>alert('Success!');window.location='../Invoices/SendInvoice.aspx';</script>");
                        return;

                    default:
                        return;
                }
            }
        }

        // Properties
        protected HttpApplication ApplicationInstance
        {
            get
            {
                return this.Context.ApplicationInstance;
            }
        }

        protected DefaultProfile Profile
        {
            get
            {
                return (DefaultProfile)this.Context.Profile;
            }
        }
    }

}
